<?php
class RegisterModule extends fvModule {

	function __construct () {
	    $moduleName = strtolower(substr(__CLASS__, 0, -6));
	    parent::__construct(fvSite::$fvConfig->get("modules.{$moduleName}.smarty.template"), 
	                        fvSite::$fvConfig->get("modules.{$moduleName}.smarty.compile"), 
	                        fvSite::$Layoult);
	}
	
	function showKcaptcha(){
		$kcaptcha = new KCAPTCHA();
		fvSite::$fvSession->set('keystring', $kcaptcha->getKeyString());
		return $kcaptcha;
	}

	function showIndex($params) {
	    $this->__assign("Customer", fvSite::$fvSession->get('Customer'));
	    $this->__assign('ERROR', fvSite::$fvSession->get('error'));
	    $this->__assign('Success', fvSite::$fvSession->get('Success'));
	    fvSite::$fvSession->set('error', null);
	    fvSite::$fvSession->set('Customer', null);
	    fvSite::$fvSession->set('Success', false);
	    return $this->__display("register.tpl");
	}
	
	function showConfirm($params) {
		$request = fvRequest::getInstance();
		if (!fvSite::$fvSession->get('uuid')){
			fvDispatcher::getInstance()->redirect(fvSite::$fvConfig->get('dir_web_root') . $request->getRequestParameter('module'));
		}
		$Customer = CustomerManager::getInstance()->getAll('MD5(CONCAT_WS("", email, full_name)) = '.'"'.fvSite::$fvSession->get('uuid').'"');
	    $this->__assign("Customer", $Customer[0]);
	    $this->__assign('error', fvSite::$fvSession->get('error'));
	    $this->__assign('Success', fvSite::$fvSession->get('Success'));
	    fvSite::$fvSession->set('error', null);
	    fvSite::$fvSession->set('Success', false);
	    fvSite::$fvSession->set('uuid', null);
	    return $this->__display("confirm.tpl");
	}
	
	function showForget($params) {
		$request = fvRequest::getInstance();
	    $this->__assign('error', fvSite::$fvSession->get('error'));
	    $this->__assign('Success', fvSite::$fvSession->get('Success'));
	    fvSite::$fvSession->set('error', null);
	    fvSite::$fvSession->set('Success', null);
	    return $this->__display("forget.tpl");
	}
	
}
?>